import http from "@/api";
import { ReqPage, ResPage } from "@/api/interface";

const baseUrl: string = "/job/log";

export interface JobLogPageParam extends ReqPage {
  // 执行bean的名称
  beanName?: string;
  // 是否成功
  succeed?: boolean;
}

export interface JobLogPageResult {
  // 定时任务id
  jobId: string;
  // 执行bean的名称
  beanName: string;
  // 执行参数
  params: string;
  // 是否成功
  succeed: boolean;
  // 错误信息
  error: string;
  // 耗时 (单位: ms)
  times: number;
  createTime: string;
}

export const getJobLogPage = (param: JobLogPageParam) => {
  return http.get<ResPage<JobLogPageResult>>(baseUrl + `/page`, param);
};

export const exportJobLogExcel = (param: JobLogPageParam) => {
  return http.get<any>(baseUrl + `/export/excel`, param, { loading: true, responseType: "blob" });
};
